﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.world {
    import flash.geom.*;
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.models.world.vos.areas.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.models.world.vos.actors.machines.*;
    import net.wooga.pets.models.world.vos.actors.*;
    import net.wooga.pets.views.world.machines.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class WorldFactory extends Actor {

		[Inject]
        public var sessionModel:SessionModel;
		[Inject]
        public var environmentModel:EnvironmentModel;
		[Inject]
        public var fileInfoModel:FileInfoModel;
        private var _classes:Dictionary;
        private var _machines:Dictionary;
        private var _configs:Dictionary;

        public function WorldFactory(){
            this._classes = new Dictionary();
            this._machines = new Dictionary();
            this._configs = new Dictionary();
            super();
            var _local1:RoomConfigVO = new RoomConfigVO();
            _local1.hasFacade = false;
            _local1.isReservable = false;
            _local1.setPosition(GameConstants.STATE_PATIENT, new Point(400, GameConstants.PATIENT_BOTTOM_OFFSET));
            _local1.setPosition(GameConstants.STATE_PATIENT, new Point(400, GameConstants.PATIENT_BOTTOM_OFFSET));
            this._configs[GameConstants.TYPE_ENTRANCE_AREA] = _local1;
            var _local2:RoomConfigVO = new RoomConfigVO();
            _local2.hasFacade = false;
            _local2.isReservable = false;
            _local2.rewardStartPos = new Point(400, -150);
            this._configs[GameConstants.TYPE_DOCK] = _local2;
            var _local3:RoomConfigVO = new RoomConfigVO();
            _local3.isReservable = false;
            _local3.machinePath = "floor/battery_machine";
            _local3.machineView = SlotMachineView;
            _local3.rewardLandingXStart = GameConstants.REWARD_ITEM_OFFSET_LEFT_WITH_AVATAR;
            _local3.rewardLandingXEnd = (GameConstants.ROOM_WIDTH - GameConstants.REWARD_ITEM_OFFSET_RIGHT);
            _local3.setPosition(GameConstants.STATE_AVATAR, new Point(200, GameConstants.AVATAR_BOTTOM_OFFSET));
            _local3.rewardStartPos = new Point(((GameConstants.ROOM_WIDTH / 2) + 150), GameConstants.REWARD_ITEM_OFFSET_BOTTOM);
            this._configs[GameConstants.TYPE_BATTERY_ROOM] = _local3;
            var _local4:RoomConfigVO = new RoomConfigVO();
            _local4.isReservable = false;
            _local4.setPosition(GameConstants.STATE_PATIENT, null);
            this._configs[GameConstants.TYPE_WAITING_ROOM] = _local4;
            var _local5:RoomConfigVO = new RoomConfigVO();
            _local5.machinePath = "floor/reception_counter";
            _local5.machineView = ReceptionMachineView;
            _local5.setPosition(GameConstants.STATE_WAITING_QUEUE, new Point(400, 580));
            this._configs[GameConstants.TYPE_RECEPTION] = _local5;
            var _local6:RoomConfigVO = new RoomConfigVO();
            _local6.machinePath = "floor/machine";
            _local6.machineView = FountainMachineView;
            _local6.setPosition(GameConstants.STATE_PATIENT, new Point(380, GameConstants.PATIENT_BOTTOM_OFFSET));
            _local6.setPosition(GameConstants.STATE_AVATAR, new Point(120, GameConstants.AVATAR_BOTTOM_OFFSET));
            this._configs[GameConstants.TYPE_FOUNTAIN] = _local6;
            var _local7:RoomConfigVO = new RoomConfigVO();
            _local7.machinePath = "wall/kiosk";
            _local7.machineView = KioskMachineView;
            _local7.setPosition(GameConstants.STATE_AVATAR, new Point(100, GameConstants.AVATAR_BOTTOM_OFFSET));
            this._configs[GameConstants.TYPE_KIOSK] = _local7;
            var _local8:RoomConfigVO = new RoomConfigVO();
            _local8.isReservable = false;
            _local8.machinePath = "floor/machine";
            _local8.machineView = KindergartenMachineView;
            _local8.setPosition((GameConstants.STATE_BABY + "_1"), new Point(170, GameConstants.BABY_BOTTOM_OFFSET));
            _local8.setPosition((GameConstants.STATE_BABY + "_2"), new Point(400, GameConstants.BABY_BOTTOM_OFFSET));
            _local8.setPosition((GameConstants.STATE_BABY + "_3"), new Point(630, GameConstants.BABY_BOTTOM_OFFSET));
            this._configs[GameConstants.TYPE_KINDERGARTEN] = _local8;
            var _local9:RoomConfigVO = new RoomConfigVO();
            _local9.isReservable = false;
            _local4.setPosition(GameConstants.STATE_WAITING_QUEUE, new Point(800, -220));
            this._configs[GameConstants.TYPE_WAITING_QUEUE] = _local4;
            this._classes[WorldConstants.BUILDING] = BuildingVO;
            this._classes[GameConstants.TYPE_KINDERGARTEN] = KindergartenVO;
            this._classes[GameConstants.TYPE_WAITING_QUEUE] = WaitingQueueVO;
            this._classes[WorldConstants.AVATAR] = {klass:AvatarVO, command:EventConstants.INIT_AVATAR};
            this._classes[WorldConstants.DOCTOR] = {klass:DoctorVO};
            this._classes[WorldConstants.BABY] = {klass:BabyVO, command:EventConstants.INIT_BABY};
            this._classes[WorldConstants.WAITING_QUEUE_PET] = {klass:WaitingPetVO, command:EventConstants.INIT_WAITING_PET};
            this._machines[GameConstants.TYPE_ENTRANCE_AREA] = EntranceMachineVO;
            this._machines[GameConstants.TYPE_RECEPTION] = ReceptionMachineVO;
            this._machines[GameConstants.TYPE_BATTERY_ROOM] = SlotMachineVO;
            this._machines[GameConstants.TYPE_WAITING_ROOM] = WaitingRoomMachineVO;
            this._machines[GameConstants.TYPE_FOUNTAIN] = FountainMachineVO;
            this._machines[GameConstants.TYPE_KIOSK] = KioskMachineVO;
            this._machines[GameConstants.TYPE_KINDERGARTEN] = KindergartenMachineVO;
            this._machines[GameConstants.TYPE_WAITING_QUEUE] = WaitingQueueMachineVO;
        }
        public function createActor(_arg1:Object):IActing{
            var _local7:InfoEvent;
            var _local2:String = _arg1[ProtocolConstants.STATE];
            var _local3:Object = ((this._classes[_local2]) || ({}));
            var _local4:Class = PatientVO;
            var _local5:String = EventConstants.INIT_PATIENT;
            if (_local3.klass){
                _local4 = Class(_local3.klass);
                _local5 = _local3.command;
            };
            var _local6:IActing = new _local4(_arg1, eventDispatcher);
            if (_local5){
                _local7 = new InfoEvent(_local5, _local2, {actor:_local6, data:_arg1});
                dispatch(_local7);
            };
            return (_local6);
        }
        public function createElement(_arg1:Object):ElementVO{
            return (new ElementVO(_arg1.id, _arg1.element_type, _arg1.room_id, _arg1.destination, _arg1.x, _arg1.y, _arg1.z, _arg1.background));
        }
        public function createArea(_arg1:Object):IArea{
            var _local4:RoomConfigVO;
            var _local5:IRoom;
            var _local6:Object;
            var _local7:RewardItemVO;
            var _local8:ContractVO;
            var _local2:Class = (((this._classes[_arg1.room_type] as Class)) || (RoomVO));
            var _local3:IArea = new _local2(_arg1);
            if ((_local3 is IRoom)){
                _local4 = new RoomConfigVO();
                _local4.machinePath = "floor/machine";
                _local4.machineView = TreatmentMachineView;
                _local4.rewardLandingXStart = GameConstants.REWARD_ITEM_OFFSET_LEFT_WITH_AVATAR;
                _local4.rewardLandingXEnd = (GameConstants.ROOM_WIDTH - GameConstants.REWARD_ITEM_OFFSET_RIGHT);
                _local5 = IRoom(_local3);
                _local5.config = (((this._configs[_local5.type] as RoomConfigVO)) || (_local4));
                _local5.machine = this.createMachine(_arg1);
                for each (_local6 in _arg1.items) {
                    _local7 = new RewardItemVO();
                    _local7.id = _local6.id;
                    _local7.itemType = _local6.item_type;
                    _local7.amount = _local6.amount;
                    _local5.rewardItems.push(_local7);
                };
                if (((_arg1.hasOwnProperty("contract")) && (!((_arg1.contract == "null"))))){
                    _local8 = new ContractVO();
                    _local8.id = _arg1.contract.id;
                    _local8.goods = _arg1.contract.goods;
                    _local8.readyAt = _arg1.contract.ready_at;
                    _local5.contract = _local8;
                };
            };
            return (_local3);
        }
        private function createMachine(_arg1:Object):IMachine{
            var _local3:IMachine;
            var _local2:Class = ((this._machines[_arg1[ProtocolConstants.ROOM_TYPE]]) || (TreatmentMachineVO));
            if ((((_arg1[ProtocolConstants.ROOM_TYPE] == GameConstants.TYPE_RECEPTION)) && (this.sessionModel.isWaitingQueueMode))){
                _local2 = ReceptionMachineQueueModeVO;
            };
            _local3 = new _local2(_arg1, eventDispatcher);
            return (_local3);
        }

    }
}//package net.wooga.pets.models.world 
